home *** CD-ROM | disk | FTP | other *** search
/ Echoes of Ireland / Echoes of Ireland.iso / html / ScormInclude.js < prev    next >
Text File  |  2004-06-10  |  2KB  |  59 lines

  1.  
  2. var findAPITries = 0;
  3.  
  4. function findAPI(win)
  5. {
  6.    // Check to see if the window (win) contains the API
  7.    // if the window (win) does not contain the API and
  8.    // the window (win) has a parent window and the parent window
  9.    // is not the same as the window (win)
  10.    while ( (win.API == null) &&
  11.            (win.parent != null) &&
  12.            (win.parent != win) )
  13.    {
  14.       // increment the number of findAPITries
  15.       findAPITries++;
  16.  
  17.       // Note: 7 is an arbitrary number, but should be more than sufficient
  18.       if (findAPITries > 7)
  19.       {
  20.          alert("Error finding API -- too deeply nested.");
  21.          return null;
  22.       }
  23.  
  24.       // set the variable that represents the window being
  25.       // being searched to be the parent of the current window
  26.       // then search for the API again
  27.       win = win.parent;
  28.    }
  29.    return win.API;
  30. }
  31.  
  32. function getAPI()
  33. {
  34.    // start by looking for the API in the current window
  35.    var theAPI = findAPI(window);
  36.  
  37.    // if the API is null (could not be found in the current window)
  38.    // and the current window has an opener window
  39.    if ( (theAPI == null) &&
  40.         (window.opener != null) &&
  41.         (typeof(window.opener) != "undefined") )
  42.    {
  43.       // try to find the API in the current windowÆs opener
  44.       theAPI = findAPI(window.opener);
  45.    }
  46.    // if the API has not been found
  47.    if (theAPI == null)
  48.    {
  49.       // Alert the user that the API Adapter could not be found
  50.       alert("Unable to find an API adapter");
  51.    }
  52.    return theAPI;
  53. }
  54.  
  55. API = getAPI();
  56.  
  57. API.LMSInitialize("");
  58. API.LMSSetValue("cmi.core.lesson_status","incomplete");
  59. API.LMSCommit("");